# -*- coding:utf-8 -*-
# 北梦测教育
# 课程咨询加微信：xiaobeiceshi
import re

# 单独写一个方法/函数来处理正则表达式
def re_match_value(string,pattern,index=0):
    """
    正则表达式提取值
    :param string: 字符串
    :param pattern: 正则表达式
    :param index: 获取第几个值，默认是0
    :return:
    """
    # matches = []
    #
    # for match in re.finditer(pattern,string):
    #     matches.append(match.group())
    # 列表推导式简化代码
    matches = [match.group(1) for match in re.finditer(pattern,string)]
    return matches[index]
